package com.atguigu.controller;

import com.atguigu.bean.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * Date:2020/9/28
 * Author:ybc
 * Description:
 */
@Controller
public class ParamController {

    @RequestMapping("/testParam")
    public String testParam(@RequestParam(value = "user_name", required = true) String username,
                            String password){
        System.out.println(username+","+password);
        return "success";
    }

    @RequestMapping("/testParamByBean")
    public String testParamByBean(User user, User abc){
        System.out.println(user);
        System.out.println(abc);
        return "success";
    }

    @RequestMapping("/testHeader")
    public String testHeader(@RequestHeader(value="Accept-Language") String acceptLanguage,
                             @RequestHeader(value = "abc", required = false, defaultValue = "xxx") String header){
        System.out.println(acceptLanguage);
        System.out.println(header);
        return "success";
    }

    @RequestMapping("/testCookie")
    public String testCookie(@CookieValue(value = "JSESSIONID") String JSESSIONID){
        System.out.println(JSESSIONID);
        return "success";
    }

}
